package com.yksj.healthtalk.ui.problemOfWall;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;

import com.yksj.healthtalk.adapter.ProblemWallMainAdapter;
import com.yksj.healthtalk.comm.BaseFragmentActivity;
import com.yksj.healthtalk.ui.R;
import com.yksj.healthtalk.ui.views.Panel;
import com.yksj.healthtalk.ui.views.PullToRefreshListView;

public class CustomerProblemMainActivity extends BaseFragmentActivity implements OnClickListener,OnItemClickListener{
	
	private Button mTitleRight	 ;
	private Button mTitleBack;
	private PullToRefreshListView mPullToRefreshListView;
	private	 ListView mListView;
	private ProblemWallMainAdapter mProblemWallMainAdapter;
	private EditText mContent ;
	private Panel panel;
	private LinearLayout container;
	private TextView mTitleName;
	
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.problem_main);
		
		initWidget();
		initClickListener();
		initData();
		
	}

	private void initClickListener() {
		// TODO Auto-generated method stub
		mTitleRight.setOnClickListener(this);
		mTitleBack.setOnClickListener(this);
		mListView.setOnItemClickListener(this);
	}

	private void initData() {
		// TODO Auto-generated method stub
		panel=new Panel(this,mPullToRefreshListView,android.view.ViewGroup.LayoutParams.FILL_PARENT,200);
		container.addView(panel);//加入Panel控件
		
		mTitleName.setText("问题墙");
		mTitleRight.setBackgroundResource(R.drawable.home_help);
		mProblemWallMainAdapter = new ProblemWallMainAdapter(this);
		mListView.setAdapter(mProblemWallMainAdapter);
	
	}

	private void initWidget() {
		// TODO Auto-generated method stub
		mTitleRight	 = (Button)findViewById(R.id.title_right);
		mTitleBack = (Button)findViewById(R.id.title_back);
		mTitleName = (TextView)findViewById(R.id.title_lable);
		mPullToRefreshListView  = (PullToRefreshListView) findViewById(R.id.hall);
		mContent  = (EditText)findViewById(R.id.et);
		mListView = mPullToRefreshListView.getRefreshableView();
		container=(LinearLayout)findViewById(R.id.container);
		}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.title_right:
			Intent intent = new  Intent(this,ComeUpWithProblemActivity.class);
			startActivity(intent);
			break;
		case R.id.title_back:
			finish();
			break;
		default:
			break;
		}
	}

	@Override
	public void onItemClick(AdapterView<?> parent, View view, int position,
			long id) {
		Intent intent = new Intent(this,CustomerProblemDetailActivity.class);
		startActivity(intent);
	}

}
